<template>
	<view class="MyStore">
		<view style="padding-bottom: 110upx;padding-top: 104upx;">
			<view class="realStore" @click="toCertifiedStore">认领门店>></view>
			<view class="MyStoreBox">
				<view class="MyStoreList">
					<view class="MyStoreItem" v-for="(item,index) in list" :key="index" :data-id="item.id" @click="toStore">
						<view class="MyStoreImage">
							<image :src="getImage(item.image_url)"></image>
						</view>
						<view class="MyStore_R">
							<view class="MyStoreName">{{item.name}}</view>
							<view class="MyStore_type">
								<view class="type">{{item.industry.name}}</view>
								<view class="giveBox">
									<u-icon name="star" color="#707070" size="30"></u-icon>
									<view class="giveNum">{{item.collection_num}}</view>
								</view>
							</view>
							<view class="MyStoreAddress">{{item.detailed_address}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="addBox" @click="toCreateStore">新增门店</view>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				page:1,
				list:[],
				moreFlag:true
			}
		},
		onShow() {
      // #ifdef APP-PLUS
      var args = plus.runtime.arguments;
      if(args){
        app.$vm.setShareDetail(args);
      }
      // #endif
			this.getList();
		},
		onReachBottom() {
			if(!this.moreFlag){
				return false;
			}
			this.moreFlag = false;
			this.page = this.page + 1;
			this.getList();
		},
		methods: {
			toCertifiedStore(){
				uni.navigateTo({
					url:"/pages/pageone/pages/CertifiedStore/CertifiedStore"
				})
			},
			toStore(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				uni.navigateTo({
					url:"/pages/pagefive/pages/StoreManagement/StoreManagement?id="+id
				})
			},
			getImage(url){
				if(url&&(url.indexOf("http://")!=-1||url.indexOf("https://")!=-1)){
					return url;
				}else{
					return app.$vm.globalData.imgBaseUrl + url;
				}
			},
			getList(){
				let obj = {};
				// obj.page = this.page;
				let newObj = {};
				obj.user_id = uni.getStorageSync("userId");
				obj.is_authentication = 1;
				newObj.page = this.page;
				newObj.data = obj;
				this.$u.api.shopList(newObj).then(res=>{
					console.log(res)
					if(this.page == 1){
						this.list = res.data.list.data;
					}else{
						this.list = this.list.concat(res.data.list.data);
					}
					if(res.data.list.last_page>this.page){
						this.moreFlag = true;
					}else{
						this.moreFlag = false;
					}
				})
			},
			//新增门店
			toCreateStore(){
				uni.navigateTo({
					url:"/pages/pagetwo/pages/CreateStore/CreateStore"
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.realStore{
		width: 100%;
		height: 72upx;
		position: fixed;
		left: 0;
		top: 16upx;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #FFF7F5;
	}
	
	
.MyStore{
	background-color: #F3F3F3;
	min-height: 100vh;
	// padding-bottom: 100upx;
	overflow: auto;
	.MyStoreBox{
		padding: 0 24upx 16upx;
		.MyStoreList{
			.MyStoreItem{
				display: flex;
				width: 702upx;
				// height: calc(144upx - 48upx);
				background: #FFFFFF;
				opacity: 1;
				border-radius: 8upx;
				padding: 24upx;
				margin-bottom: 16upx;
				.MyStoreImage{
					width: 96upx;
					height: 96upx;
					// background-color: #F0AD4E;
					border-radius: 8upx;
					image{
						width: 100%;
						height: 100%;
						border-radius: 8upx;
					}
				}
				.MyStore_R{
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					width: calc(100% - 112upx);
					margin-left: 16upx;
					.MyStoreName{
						font-size: 20upx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #333333;
					}
					.MyStore_type{
						display: flex;
						justify-content: space-between;
						align-items: center;
						margin-top: 16upx;
						.type{
							font-size: 20upx;
							font-family: Source Han Sans CN;
							font-weight: 400;
							color: #999999;
						}
						.giveBox{
							display: flex;
							align-items: center;
							.giveNum{
								font-size: 20upx;
								font-family: Source Han Sans CN;
								font-weight: 400;
								color: #999999;
								margin-left: 8upx;
							}
						}
					}
					.MyStoreAddress{
						font-size: 16upx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #999999;
						margin-top: 16upx;
					}
				}
			}
		}
	}
	.addBox{
		position: fixed;
		bottom: 0;
		width: 750upx;
		height: 100upx;
		background: #FFAC3F;
		opacity: 1;
		font-size: 28upx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		line-height: 100upx;
		text-align: center;
		color: #FFFFFF;
	}
}
</style>
